//
//  LoginRootViewController.m
//  CarTown
//
//  Created by 熊浩 on 15/7/30.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "LoginRootViewController.h"
#import "SearchViewController.h"
#import "RootTabViewController.h"
@interface LoginRootViewController ()

@end

@implementation LoginRootViewController

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupNavBar:NO];
    // 禁用 iOS7 返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    [super pushViewController:viewController animated:animated];
    
    if ([viewController isKindOfClass:[RootTabViewController class]]) {
        self.navigationBar.hidden=YES;
    }else{
         [self setupNavBar:NO];
        
    UIButton *backbtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [backbtn setImage:[UIImage imageNamed:@"back_ico"] forState:UIControlStateNormal];
    CGSize backsize=backbtn.currentImage.size;
    backbtn.frame=CGRectMake(0, 0, backsize.width, backsize.height);
    
    [backbtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    
    viewController.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:backbtn];
    }
}
-(void)menu{
    
}

-(void)setupNavBar:(BOOL)issearch{
    if (issearch) {
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}
         ];
        [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"whilte_navbg"] forBarMetrics:UIBarMetricsDefault];
        [self.navigationBar setTranslucent:YES];
        
        [self.navigationBar setTintColor:[[UIColor alloc]initWithRed:46/255.0 green:141/255.0 blue:215/255.0 alpha:1.0]];
    }else{
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}
         ];
        [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbg"] forBarMetrics:UIBarMetricsDefault];
        [self.navigationBar setTranslucent:YES];
        [self.navigationBar setTintColor:[UIColor whiteColor]];
    }
}
-(void)back{
    [self popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
